﻿using System;
using System.Linq;
using DevExpress.Xpo;

namespace RemoteImaging.LicensePlate
{
    public class LicensePlateCheckService : ILicensePlateCheckService
    {
        private Session _session;

        public LicensePlateCheckService()
        {
            _session = new Session();
        }

        public void Check(string licensePlateNumber, Action<ReportedCarInfo> callback)
        {
            var query = new XPQuery<ReportedCarInfo>(_session);
            var carInfos = from i in query
                           where i.LicenseNumber == licensePlateNumber
                           select i;

            callback(carInfos.FirstOrDefault());
        }
    }
}